package com.education.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 系统通知表
 *
 * @author education-platform
 * @since 2025-10-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("notification")
@JsonIgnoreProperties(value = {"handler"})
public class Notification {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 通知标题
     */
    @TableField("title")
    private String title;

    /**
     * 通知内容
     */
    @TableField("content")
    private String content;

    /**
     * 通知类型
     */
    @TableField("type")
    private String type;

    /**
     * 优先级
     */
    @TableField("priority")
    private String priority;

    /**
     * 目标用户
     */
    @TableField("target_users")
    private String targetUsers;

    /**
     * 用户ID列表
     */
    @TableField("user_ids")
    private String userIds;

    /**
     * 链接地址
     */
    @TableField("link_url")
    private String linkUrl;

    /**
     * 状态
     */
    @TableField("status")
    private String status;

    /**
     * 是否定时发送
     */
    @TableField("scheduled")
    private Boolean scheduled;

    /**
     * 发送时间
     */
    @TableField("send_time")
    private LocalDateTime sendTime;

    /**
     * 实际发送时间
     */
    @TableField("sent_at")
    private LocalDateTime sentAt;

    /**
     * 发送人数
     */
    @TableField("send_count")
    private Integer sendCount;

    /**
     * 已读人数
     */
    @TableField("read_count")
    private Integer readCount;

    /**
     * 创建人ID
     */
    @TableField("created_by")
    private Long createdBy;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    // 枚举定义
    public enum Type {
        SYSTEM("系统通知"),
        ACTIVITY("活动通知"),
        ANNOUNCEMENT("公告通知");

        private final String description;

        Type(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum Priority {
        LOW("低"),
        NORMAL("普通"),
        HIGH("高"),
        URGENT("紧急");

        private final String description;

        Priority(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum Status {
        DRAFT("草稿"),
        PENDING("待发送"),
        SENT("已发送");

        private final String description;

        Status(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum TargetUsers {
        ALL("全部用户"),
        TEACHER("所有教员"),
        PARENT("所有家长"),
        CUSTOM("指定用户");

        private final String description;

        TargetUsers(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
}

